Units Used in CSS Rotation
In CSS, rotation angles in the rotate() function are defined using angle units. These units determine how much an element is rotated clockwise or counterclockwise around its origin point.
deg — degrees. A full circle equals 360deg (most commonly used).
rad — radians. A full circle equals approximately 6.2832 radians (2π).
grad — gradians. A full circle equals 400grads.
turn — turns. A full circle equals 1turn.
While all these units are valid, deg (degrees) is most widely used for simplicity and readability.
Use positive angles for clockwise rotation and negative angles for counterclockwise rotation.
You can animate between different rotation units using transition or animation.
You need to rotate an icon 90 degrees clockwise using CSS. How would you write the rule, and which unit would you use?
If you write transform: rotate(0.5); what will happen in the browser and why?
A component that uses rotate(45) stopped rotating after a recent refactor. Walk me through how you'd debug the issue.
When animating a spinner, you notice the rotation speed is inconsistent across browsers. How does the choice of unit (deg vs rad) affect this, and what would you choose?
Our design system defines rotation values in turn units for consistency, but many existing components use deg. How would you approach refactoring the codebase to adopt a single unit without breaking production?
Explain the performance implications, if any, of using rotate(0.5turn) versus rotate(180deg) in a high‑frequency animation on a page with thousands of elements.
We are building a cross‑platform UI library that needs to generate CSS for both web and native (React Native) targets. How would you design an abstraction for rotation that handles unit differences and ensures maintainability across teams?
A legacy product uses custom JavaScript to compute rotation angles in radians and injects them into CSS. What strategy would you propose to migrate to a declarative CSS approach while minimizing risk and technical debt?